package com.example.fragement_newsdemo;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

public class NewsContentFragment  extends Fragment {
    private View view;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.news_content_fragment, container, false);
        return view;
    }

    public void refresh(String newTitle, String newContent) {
        View mLinearLayout = view.findViewById(R.id.ll_layout);
        mLinearLayout.setVisibility(View.VISIBLE);
        TextView mTvTitle = view.findViewById(R.id.tv_title);
        TextView mTvContent = view.findViewById(R.id.tv_content);

        mTvTitle.setText(newTitle);
        mTvContent.setText(newContent);
    }
}
